#include <stdio.h>

void function_sort(int array[], int num);
void function_input(int array[], int num);
void function_output(int array[], int num);

int main(){
    int array[100];
    int number = 0;
    printf("How many numbers?\n");
    scanf("%d",&number);
    function_input(array,number);
    function_sort(array,number);
    function_output(array,number);
    return 0;
}

void function_input(int array[], int num){
    int i;
    printf("Please input! \n");
    for (i=0;i<num;i++)
        scanf("%d",&array[i]);
}

void function_sort(int array[], int num){
    int i,j,temp = 0;
    for(i=0;i<num-1;i++) {
        for (j=i+1;j<num;j++) {
            if(array[i]>array[j]){
                temp = array[i];
                array[i] = array[j];
                array[j] = temp;
            }
        }
    }
}

void function_output(int array[], int num){
    int j;
    printf("After sort :");
    for (j=0;j<num;j++)
            printf("%-3d",array[j]);/*-3d表示左对齐，占3位*/
    printf("\n");/*每一行后换行*/
}
